#ifndef __SDP_H__
#define __SDP_H__
#include <list>
#include <string>

#include "OSHeaders.h"


#define SDP_ERR_NOSTREAM	-100
#define SDP_ERR_NOSTREAMID	-101
#define SDP_ERR_NOSTREAMID_NUM	-102

class CSDP {
 public:
	CSDP();
	~CSDP();
	
	const char *GetSDP();
	Bool Load(char *v_str);
	Bool LoadFromFile(const char *v_fn);
	void ResetSdp(const std::string strNewSdp)
	{
		m_sdp = strNewSdp;
	}
	
 public:
	/*
		v_port: start port
		v_pnum: total ports
		v_flag: UDP  / TCP
	 */
	enum { UDP=0, TCP=1};
	enum {VIDEO=1, AUDIO=2,APPLICATION=3};
	Bool AppendControlField();

	//TrackID/streamID operand
	Int32 GetStreamID(char *v_Str,char *outStr,UInt32 &outID);
	Bool ModifyStreamID(char *v_Str, char *v_NewStr);
	Bool ModifyConnectionIP(char *v_str);
	Bool RemoveTrackID();
	Bool AppendTrackID(UInt8 v_type,UInt32 v_id);

	Bool GetConnectionIP(char *v_ip,UInt16 *v_ttl);
	Bool GetServerAddr(char *v_str);
	Bool GetServerPort(UInt8 v_type,UInt16 *v_port, UInt8 *v_pnum, UInt8 *v_flag);
	Bool GetTimeScale(UInt8 v_type,UInt32 *v_TimeScale);
	Bool SetServerPort(UInt8 v_type,UInt16 v_port);
	
	Bool ModifyLine(char *v_Line,char *v_Str);

	//remove the lines include v_str
	Bool RemoveLines(char *v_str);

	Bool GetRange(Float32 &v_StartTime, Float32 &v_EndTime);


 protected:
	Bool Find(char *v_str,Int32 *v_PosStart,Int32 *v_PosEnd,Int32 v_Start=0);
	
 private:
	std::string m_sdp;
};
#endif	//__SDP_H__

